from django.core.management.base import BaseCommand
from apps.product.models import *
from apps.user.models import *
from apps.order.models import *
from typing import List


class Command(BaseCommand):
    def handle(self, *args, **options):
        sos = SubOrder.objects.filter(create_type=SubOrder.CreateType.TAKE_OUT.name, order__status__in=[Order.Status.PAYED.name, Order.Status.FINISHED.name])
        gb_ids = [so.goods_block_id for so in sos]
        GoodsBlock.objects.filter(id__in=gb_ids).update(taken_out=True)